package com.leo.producer.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration
@RequiredArgsConstructor
public class MqConfig {

    private final RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setReturnsCallback(returnCallback -> {
            log.error("触发return callback");
            log.debug("Exchange:[{}]", returnCallback.getExchange());
            log.debug("RoutingKey:[{}]", returnCallback.getRoutingKey());
            log.debug("Message:[{}]", returnCallback.getMessage());
            log.debug("ReplyCode:[{}]", returnCallback.getReplyCode());
            log.debug("ReplyText:[{}]", returnCallback.getReplyText());
        });

    }

}
